package com.sl.plugin.step.selenium.js;

import cn.hutool.core.util.StrUtil;
import com.sl.core.engine.meta.impl.AbstractProcessCompDescriptor;
import com.sl.core.engine.step.ProcessCompService;
import com.sl.core.engine.step.impl.AbstractProcessComp;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
/**
 */
public class SeleniumJsComp extends AbstractProcessComp<WebDriver, WebDriver> implements ProcessCompService {


    public SeleniumJsComp(AbstractProcessCompDescriptor abstractProcessCompDescriptor) {
        super(abstractProcessCompDescriptor);
    }



    @Override
    public WebDriver input(WebDriver driver) {
        String time = meta.getStrAttr("js");
        if(StrUtil.isBlank(time)){
            return driver;
        }
        JavascriptExecutor js = (JavascriptExecutor) driver;

        js.executeScript(time);
        return driver;
    }


}
